package app.blog.test;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

import org.apache.commons.javaflow.Continuation;

public class MyRunnable {
	
	public <T> T echo(Future<T> future) {
		if (future.isDone()) {
			try {
				return future.get();
			} catch (InterruptedException e) {
				e.printStackTrace();
			} catch (ExecutionException e) {
				e.printStackTrace();
			}
		} else {
			Continuation.suspend(future);
			return null;
		}
		return null;
	}
}